import http from '@/api/http'
import { BASEURL } from '@/control'// 服务器地址

function filterReqStr(requestData) {
  for (var key in requestData) {
    if (requestData[key] == '' && (requestData[key] != 0)) {
      delete requestData[key]
    }
  }
  return requestData
} // 遍历前端请求数据，删除空的

function filterAddress(requestData) {
  for (var key in requestData) {
    let arr = Object.keys(requestData[key])
    if (arr.length == 0) {
      delete requestData[key]
    }
  }
  return requestData
} // 遍历前端请求数据，删除空的
/** ***http.post******http.get*****ajax*******/

export function login(params) {
  return http.post('/backend/acc/login', params)
}// post API
export function downexcelMerchant_recharge(params) {
  return http.post('/backend/merchant_recharge/downexcel', params, 'blob')
}// excel数据下载

/** **************************上传接口******************************/
export const uploadFileAddress = BASEURL + '/purchase/file/uploadFile'
export function uploadFileApi(params) {
  return http.post('/file/uploadFile', params)
}// 上传文件

/** **************************账号***********************************/
export function loginUserApi(params) {
  return http.post('/sys/login', params)
}// 账号-登陆
export function editUserApi(params) {
  return http.post('/sys/edit/info', params)
}// 账号修改信息
export function logoutUserApi(params) {
  return http.post('/sys/logout', params)
}// 退出登陆
export function newpwdEditApi(params) {
  return http.post('/sys/edit/newpwd', params)
}// 账号修改密码
export function resetpwdApi(params) {
  return http.post('/sys/edit/resetpwd', params)
}// 账户重置密码
export function rePwdMailApi(params) {
  return http.post('/sys/mail/rePwd', params)
}//  通过邮件验证码重置密码
export function forgetPwdApi(params) {
  return http.post('/sys/forgetPwd', params)
}// 忘记密码，进行重置
// export function menuSysApi(params) {
//   return http.post('/sys/menu', params)
// }// 当前账户菜单列表查询
export function infoUserApi(params) {
  return http.post('/sys/user/info', params)
}// 账户登录后，返回用户信息

/** **************************商品分类***********************************/
export function queryCategoryApi(params) {
  return http.post('/category/query', params)
}// 分页查询产品分类
export function newCategoryApi(params) {
  return http.post('/category/new', params)
}// 新增产品分类
export function editCategoryApi(params) {
  return http.post('/category/edit', params)
}// 修改产品分类
export function infoCategoryTypeApi(params) { // 1111111111111111111111111111111
  return http.post('/category/category/info', params)
}// 回显产品分类
export function deleteCategoryApi(params) {
  return http.post('/category/delete', params)
}// 删除产品目录
export function queryShopCategoryApi(params) {
  return http.post('/category/queryShop', params)
}// 分页查询商店产品目录

/** **************************商品类***********************************/
export function queryProductApi(params) {
  return http.post('/product/query', params)
}// 分页查询商品
export function query_shop_detailsProductApi(params) {
  return http.post('/product/query_shop_details', params)
}// 查询商品详情
export function product_product_newApi(params) {
  return http.post('/product/new', params)
}// 新增商品
export function editProductApi(params) {
  return http.post('/product/edit', params)
}// 修改商品
export function deleteProductApi(params) {
  return http.post('/product/delete', params)
}// 删除商品
export function queryShopProductApi(params) {
  return http.post('/product/queryShop', params)
}//  分页查询商店商品

/** **************************异常日志***********************************/
export function exception_log_queryApi(params) {
  return http.post('/exception_log/query', params)
}// 查询异常日志
/** **************************操作日志***********************************/
export function operation_log_queryApi(params) {
  return http.post('/operation_log/query', params)
}// 查询操作日志
// /** **************************权限表***********************************/
// export function permission_delApi(params) {
//   return http.post('/permission/del', params)
// }// 权限删除
// export function permission_editApi(params) {
//   return http.post('/permission/edit', params)
// }// 权限编辑
// export function permission_newApi(params) {
//   return http.post('/permission/new', params)
// }// 权限新建
// export function permission_queryApi(params) {
//   return http.post('/permission/query', params)
// }// 权限查询
/** **************************用户角色***********************************/
// export function user_role_delApi(params) {
//   return http.post('/user_role/del', params)
// }// 角色删除
// export function user_role_newApi(params) {
//   return http.post('/user_role/new', params)
// }// 用户角色新建
// export function user_role_queryApi(params) {
//   return http.post('/user_role/query', params)
// }// 用户角色查询
/** **************************经销商***********************************/
export function applayDealerApi(params) {
  return http.post('/dealer/applay', params)
}// 注册经销商户
export function deleteDealerApi(params) {
  return http.post('/dealer/delete', params)
}// 根据经销商id删除
export function verifyMdealerApi(params) {
  return http.post('/dealer/mdealer/verify', params)
}// 主经销商
export function newDealerApi(params) {
  return http.post('/dealer/new', params)
}// 创建经销商户
export function editDealerApi(params) {
  return http.post('/dealer/edit', params)
}// 修改经销商户
export function editaddrDealerApi(params) {
  return http.post('/dealer/editaddr', filterAddress(params))
}// 修改经销商户
export function verifyMdealerDealerApi(params) {
  return http.post('/dealer/mdealer/verify', params)
}// 经销商申请注册，主经销商认证通过,后由持有者批准
export function passOwnerDealerApi(params) {
  return http.post('/dealer/owner/pass', params)
}// 持有者通过经销商的注册申请
export function queryDealerApi(params) {
  return http.post('/dealer/query', params)
}// 分页查询主经销商
export function query_dealerDealerApi(params) {
  return http.post('/dealer/query_dealer', params)
}// 查询主经销商下面的所有经销商
export function adminQueryDealerApi(params) {
  return http.post(' /dealer /admin_query_dealer', params)
}// 仪表盘查询经销商
export function query_masterDealerApi(params) {
  return http.post('/dealer/query_master', params)
}// 查询全部主经销商
export function dealer_query_oneApi(params) {
  return http.post('/dealer/query_one', params)
}// 根据经销商id查询经销商
export function registpayDealerApi(params) {
  return http.post('/dealer/registpay', params)
}// 支付经销商服务费
export function mailVerifyDealerApi(params) {
  return http.post('/dealer/verify/mail', params)
}// 电子邮箱认证
/** **************************角色***********************************/
// export function role_delApi(params) {
//   return http.post('/role/del', params)
// }// 角色删除
// export function role_editApi(params) {
//   return http.post('/role/edit', params)
// }// 角色修改
// export function role_newApi(params) {
//   return http.post('/role/new', params)
// }// 角色新建
// export function role_queryApi(params) {
//   return http.post('/role/query', params)
// }// 角色查询
/** **************************经销商产品***********************************/
export function editDealer_productApi(params) {
  return http.post('/dealer_product/edit', params)
}//  修改主经销商产品
export function queryDealer_productApi(params) {
  return http.post('/dealer_product/query', params)
}//  分页查询主经销商产品
/** **************************经销商产品目录***********************************/
export function editDealer_categoryApi(params) {
  return http.post('/dealer_category/edit', params)
}// 编辑主经销商产品目录
export function queryDealer_categoryApi(params) {
  return http.post('/dealer_category/query', params)
}//  分页查询主经销商产品目录

/** **************************角色权限***********************************/
// export function role_permission_delApi(params) {
//   return http.post('/role_permission/del', params)
// }// 角色权限删除
// export function role_permission_newApi(params) {
//   return http.post('/role_permission/new', params)
// }// 角色权限新增
// export function role_permission_queryApi(params) {
//   return http.post('/role_permission/query', params)
// }// 角色权限查询
/** **************************订单购物车***********************************/
export function order_addtocartApi(params) {
  return http.post('/order/addtocart', params)
}// 添加商品到购物车
export function order_clearcartApi(params) {
  return http.post('/order/clearcart', params)
}// 清空购物车
export function order_delcartApi(params) {
  return http.post('/order/delcart', params)
}// 删除购物车商品
export function order_editcartApi(params) {
  return http.post('/order/editcart', params)
}// 修改购物车商品数量
export function order_invoice_queryApi(params) {
  return http.post('/order/invoice/query', params)
}// 查询所有订单的发票
export function order_newApi(params) {
  return http.post('/order/new', params)
}// 创建订单
export function admin_addOrderApi(params) {
  return http.post('/order/admin_add', params)
}// 管理员创建订单
export function delOrderApi(params) {
  return http.post('/order/del', params)
}//  删除订单
export function myorder_queryApi(params) {
  return http.post('/order/query/myorder', params)
}//  我的订单查询
export function orderRecentApi(params) {
  return http.post('/dashboard/recent/order', params)
}// 查询最近订单
export function order_queryApi(params) {
  return http.post('/order/query', params)
}// 订单查询
export function order_editApi(params) {
  return http.post('/order/edit', params)
}// 修改订单状态
export function order_querycartApi(params) {
  return http.post('/order/querycart', params)
}// 查询购物车
export function queryinfoInvoiceApi(params) {
  return http.post('/order/invoice/queryinfo', params)
}// 通过单号查询发票详情
export function queryinfoOrderApi(params) {
  return http.post('/order/queryinfo', params)
}//  通过单号查询订单详情
export function infoMyorderApi(params) {
  return http.post('/order/query/myorder/info', params)
}// 通过单号查询我的订单详情

/** **************************查询仪表盘***********************************/
export function adminDashboardApi(params) {
  return http.post('/dashboard/admin', params)
}// 管理员查询仪表盘
export function agentDashboardApi(params) {
  return http.post('/dashboard/agent', params)
}// 大代理查询仪表盘
export function dealerDashboardApi(params) {
  return http.post('/dashboard/dealer', params)
}// 经销商仪表盘
export function masterdealerDashboardApi(params) {
  return http.post('/dashboard/masterdealer', params)
}// 主经销商查询仪表盘
export function queryDealerDashboardApi(params) {
  return http.post('/dealer/dashboard_query_dealer', params)
}//

/** **************************统计报告***********************************/
export function adminReportApi(params) {
  return http.post('report/admin', params)
}// 查询统计报告
export function masterDealerReportApi(params) {
  return http.post('/report/masterdealer', params)
}// 主经销商查询统计报告
export function salesMasterDealerReportApi(params) {
  return http.post('/report/masterdealer/sales/page', params)
}// 查询主经销商汇总数据分页查询
export function salesAll_master_dealerApi(params) {
  return http.post('/report/all_master_dealer/sales', params)
}// 所有主经销商销售报告|某主经销商下经销商报告
export function salesProductReportApi(params) {
  return http.post('/report/product/sales', params)
}//   产品销售报告
export function transactionOnlineApi(params) {
  return http.post('/report/online/transaction', params)
}//   线上交易报告

// export function Api(params) {
//   return http.post('sssssdel', params)
// }// 角色权限删除

// import { order_invoice_queryApi } from '@/api/user'
